{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import nvstrings, nvcategory"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "s1 = nvstrings.to_device(['a','a','d','c','c','e'])\n",
    "s2 = nvstrings.to_device(['a','b','b','f','c','f'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "c1 = nvcategory.from_strings(s1)\n",
    "c2 = nvcategory.from_strings(s2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['a', 'c', 'd', 'e'] [0, 0, 2, 1, 1, 3]\n",
      "['a', 'b', 'c', 'f'] [0, 1, 1, 3, 2, 3]\n"
     ]
    }
   ],
   "source": [
    "print(c1.keys(),c1.values())\n",
    "print(c2.keys(),c2.values())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['a', 'c', 'd', 'e', 'b', 'f'] [0, 0, 2, 1, 1, 3, 0, 4, 4, 5, 1, 5]\n"
     ]
    }
   ],
   "source": [
    "nc = c1.merge_category(c2)\n",
    "print(nc.keys(),nc.values())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['a', 'b', 'e', 'g'] [1, 0, 0, 2, 3, 1]\n"
     ]
    }
   ],
   "source": [
    "s22 = nvstrings.to_device(['b','a','a','e','g','b'])\n",
    "c22 = nvcategory.from_strings(s22)\n",
    "print(c22.keys(), c22.values())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['a', 'c', 'd', 'e', 'b', 'f', 'g'] [0, 0, 2, 1, 1, 3, 0, 4, 4, 5, 1, 5, 4, 0, 0, 3, 6, 4]\n"
     ]
    }
   ],
   "source": [
    "nc = nc.merge_category(c22)\n",
    "print(nc.keys(),nc.values())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['a', 'b', 'e', 'g', 'c', 'd', 'f'] [1, 0, 0, 2, 3, 1, 0, 0, 5, 4, 4, 2, 0, 1, 1, 6, 4, 6]\n"
     ]
    }
   ],
   "source": [
    "nc = c1.merge_category(c2)\n",
    "nc = c22.merge_category(nc)\n",
    "print(nc.keys(),nc.values())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['a', 'b', 'c', 'f', 'd', 'e'] [0, 1, 1, 3, 2, 3, 0, 0, 4, 2, 2, 5]\n"
     ]
    }
   ],
   "source": [
    "nc = c2.merge_category(c1)\n",
    "print(nc.keys(),nc.values())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
